HAL MMC types migration ¶
This section provides information about the HAL MMC types migration.
HAL MMC state type definition ¶
|
HAL1 |
HAL2 |
|---|---|
typedef enum
{
HAL_MMC_STATE_RESET,
HAL_MMC_STATE_TIMEOUT,
HAL_MMC_STATE_READY,
HAL_MMC_STATE_PROGRAMMING,
HAL_MMC_STATE_RECEIVING,
HAL_MMC_STATE_TRANSFER,
HAL_MMC_STATE_BUSY,
HAL_MMC_STATE_ERROR
} HAL_MMC_StateTypeDef;
|
typedef enum
{
HAL_MMC_STATE_RESET,
HAL_MMC_STATE_INIT,
HAL_MMC_STATE_CARD_REMOVED,
HAL_MMC_STATE_IDLE,
HAL_MMC_STATE_ACTIVE,
HAL_MMC_STATE_ABORT
} hal_mmc_state_t;
|
Related concept: Revised and optimized HAL state machine
HAL MMC card state type definition ¶
|
HAL1 |
HAL2 |
|---|---|
#define HAL_MMC_CARD_IDLE
#define HAL_MMC_CARD_READY
#define HAL_MMC_CARD_IDENTIFICATION
#define HAL_MMC_CARD_STANDBY
#define HAL_MMC_CARD_TRANSFER
#define HAL_MMC_CARD_SENDING
#define HAL_MMC_CARD_RECEIVING
#define HAL_MMC_CARD_PROGRAMMING
#define HAL_MMC_CARD_DISCONNECTED
#define HAL_MMC_CARD_BUSTEST
#define HAL_MMC_CARD_SLEEP
#define HAL_MMC_CARD_ERROR
typedef uint32_t HAL_MMC_CardStateTypeDef
|
typedef enum {
HAL_MMC_CARD_IDLE,
HAL_MMC_CARD_READY,
HAL_MMC_CARD_IDENTIFICATION,
HAL_MMC_CARD_STANDBY,
HAL_MMC_CARD_TRANSFER,
HAL_MMC_CARD_SENDING,
HAL_MMC_CARD_RECEIVING,
HAL_MMC_CARD_PROGRAMMING,
HAL_MMC_CARD_DISCONNECTED,
HAL_MMC_CARD_BUSTEST,
HAL_MMC_CARD_SLEEP,
HAL_MMC_CARD_ERROR
} hal_mmc_card_state_t;
|
Related concept: Replace Finite Parameter Defines (Including PPP Instances) with Enum Types at HAL Levels.
HAL MMC initialization type definition ¶
In HAL2, clock settings are grouped in the
hal_mmc_clock_config_t
structure inside
hal_mmc_config_t.
|
HAL1 |
HAL2 |
|---|---|
#define MMC_InitTypeDef SDMMC_InitTypeDef
typedef struct
{
uint32_t ClockEdge,
uint32_t ClockPowerSave,
uint32_t ClockDiv,
uint32_t BusWide,
uint32_t HardwareFlowControl,
} SDMMC_InitTypeDef
|
typedef struct
{
typedef struct
{
hal_mmc_clock_edge_t clk_edge,
hal_mmc_clock_power_save_t clk_power_save,
#if defined (USE_HAL_MMC_AUTO_DETECTION_FREQUENCY) && (USE_HAL_MMC_AUTO_DETECTION_FREQUENCY == 0)
uint32_t clk_hz,
/* ClockDiv is replaced by clk_hz see below note for details */
#endif
} hal_mmc_clock_config_t
hal_mmc_bus_wide_t bus_wide,
hal_mmc_hardware_flow_control_t hw_flow_ctrl,
uint32_t data_timeout_cycle,
uint32_t stop_xfer_timeout_ms,
uint32_t erase_timeout_ms
} hal_mmc_config_t
|
Note
In HAL1, the user had to provide the clock divider manually, by choosing from the defined division factors in SDMMC layer (SDMMC_NSPEED_CLK_DIV, SDMMC_HSPEED_CLK_DIV…).
In HAL2, the user provides the clock frequency, and the clock divider calculation is done internally based on the provided frequency. Enabling
USE_HAL_MMC_AUTO_DETECTION_FREQUENCYlets HAL2 select the clock division to match the highest frequency.
HAL MMC instances type definition ¶
Note
In HAL1, this define was a redirection to
device.hto provide the MMC instance.In HAL2, the instances are provided with the following enumeration type.
|
HAL1 |
HAL2 |
|---|---|
#define MMC_TypeDef
|
Removed; use the following enumerated type instead:
|
HAL MMC card information type definition ¶
|
HAL1 |
HAL2 |
|---|---|
typedef struct
{
uint32_t CardType,
uint32_t Class,
uint32_t RelCardAdd,
uint32_t BlockNbr,
uint32_t BlockSize,
uint32_t LogBlockNbr,
uint32_t LogBlockSize
} HAL_MMC_CardInfoTypeDef
|
typedef struct
{
/* Removed; See the below note for details. */
/* Removed; See the below note for details. */
uint32_t relative_addr,
uint32_t block_nbr,
uint32_t block_size_byte,
uint32_t logical_block_nbr,
uint32_t logical_block_size_byte,
} hal_mmc_card_info_t
|
Note
- CardType field:
-
In HAL1, the CardType field was used internally to identify the card type (High or low capacity).
In HAL2 this has been removed from the exported structure and maintained only for internal usage within the HAL driver.
- Class field:
-
In HAL1, the Class field has been used to store the card’s CCC register (Card Command Class), used internally to identify the command sets supported by the card.
In HAL2 this has been removed; not needed as HAL driver only covers the mandatory commands supported by all MMC cards.
HAL MMC handle object type definition ¶
|
HAL1 |
HAL2 |
|---|---|
MMC_HandleTypeDef
|
hal_mmc_handle_t
|
HAL MMC card CSD register type definition ¶
|
HAL1 |
HAL2 |
|---|---|
HAL_MMC_CardCSDTypeDef
|
Removed; in HAL2 the Card Specific Data are handled internally by the driver. Thus this structure and the related HAL_MMC_GetCSD() are removed. |
HAL MMC card CID register type definition ¶
|
HAL1 |
HAL2 |
|---|---|
typedef struct
{
__IO uint32_t ProdName1,
__IO uint32_t ProdSN,
__IO uint16_t OEM_AppliID,
__IO uint16_t ManufactDate,
__IO uint8_t ManufacturerID,
__IO uint8_t CID_CRC,
__IO uint8_t Reserved2,
__IO uint8_t ProdName2,
__IO uint8_t ProdRev,
__IO uint8_t Reserved1
} HAL_MMC_CardCIDTypeDef;
|
typedef struct
{
uint32_t product_name_part1,
uint32_t product_serial_nbr,
uint16_t oem_app_id,
uint16_t manufacturer_date,
uint8_t manufacturer_id,
uint8_t cid_crc,
uint8_t reserved2,
uint8_t product_name_part2,
uint8_t product_rev,
uint8_t reserved1
} hal_mmc_card_cid_t;
|
HAL MMC callback ID type definition ¶
|
HAL1 |
HAL2 |
|---|---|
typedef enum
{
HAL_MMC_TX_CPLT_CB_ID,
HAL_MMC_RX_CPLT_CB_ID,
HAL_MMC_ERROR_CB_ID,
HAL_MMC_ABORT_CB_ID,
HAL_MMC_READ_DMA_LNKLST_BUF_CPLT_CB_ID,
HAL_MMC_WRITE_DMA_LNKLST_BUF_CPLT_CB_ID,
HAL_MMC_READ_DMA_DBL_BUF0_CPLT_CB_ID,
HAL_MMC_READ_DMA_DBL_BUF1_CPLT_CB_ID,
HAL_MMC_WRITE_DMA_DBL_BUF0_CPLT_CB_ID,
HAL_MMC_WRITE_DMA_DBL_BUF1_CPLT_CB_ID,
HAL_MMC_MSP_DEINIT_CB_ID,
HAL_MMC_MSP_DEINIT_CB_ID
} HAL_MMC_CallbackIDTypeDef;
|
Removed. Note The callback registration in HAL2 is handled by specific functions for each MMC event. The update from HAL 1 to HAL 2 involves a significant change in the way callback functions are registered for MMC events. Refer to HAL MMC callback registration. |
- Related concepts:
HAL MMC callback pointer type definition ¶
HAL2 splits callbacks:
hal_mmc_cb_t
handles simple Error/Abort cases, while
hal_mmc_xfer_cb_t
adds an event parameter to distinguish transfer completions (standard complete TX/RX and node complete TX/RX).
|
HAL1 |
HAL2 |
|---|---|
typedef void (*pMMC_CallbackTypeDef)(MMC_HandleTypeDef *hmmc)
|
typedef void (*hal_mmc_cb_t)(hal_mmc_handle_t *hmmc)
typedef void (*hal_mmc_xfer_cb_t)(hal_mmc_handle_t *hmmc, hal_mmc_event_cb_t cb_event);
|
HAL MMC internal DMA buffer type definition ¶
|
HAL1 |
HAL2 |
|---|---|
HAL_MMCEx_DMAbuffer_MemoryTypeDef
|
Multi-buffering is available only in some STM32 series. These series are not yet supported in HAL2. |
HAL MMC DMA link node configuration type definition ¶
|
HAL1 |
HAL2 |
|---|---|
#define MMC_DMALinkNodeConfTypeDef SDMMC_DMALinkNodeConfTypeDef
typedef struct
{
uint32_t BufferAddress,
uint32_t BufferSize
} SDMMC_DMALinkNodeConfTypeDef
|
Removed; In HAL2, linked-list node’s
|
HAL MMC DMA link node type definition ¶
|
HAL1 |
HAL2 |
|---|---|
#define MMC_DMALinkNodeTypeDef SDMMC_DMALinkNodeTypeDef
typedef struct
{
__IO uint32_t IDMALAR,
__IO uint32_t IDMABASER,
__IO uint32_t IDMABSIZE
} SDMMC_DMALinkNodeTypeDef
|
typedef struct
{
uint32_t idma_node_offset,
uint32_t idma_buffer_base_addr,
uint32_t idma_buffer_size
} hal_mmc_node_t
|
Note
The linked list operations have been restructred in HAL2. Refer to HAL MMC linked-list DMA operations and to the use case for linked list management.
HAL MMC DMA linked-list type definition ¶
|
HAL1 |
HAL2 |
|---|---|
MMC_DMALinkedListTypeDef
|
Removed; HAL2 introduces a unified queue structure for linked list management. Refer to
HAL MMC linked-list DMA operations.
To define a linked list in HAL2, use the
|
|
HAL1 |
HAL2 |
|---|---|
MMC_DMALinkedListTypeDef my_linked_list;
|
hal_q_t my_linked_list;
HAL_Q_Init(&my_linked_list, HAL_MMC_DescOps);
|